Skip to content

Read Leica PTG binary TLV headers and transposed scanner poses - #93

Merged
mahach666 merged 1 commit into
mainfrom
codex/ptg-binary-header
Nov 25, 2026
Merged

mahach666 merged 1 commit into
mainfrom
codex/ptg-binary-header

Conversation

@mahach666

Copy link
Copy Markdown
Contributor

What

Leica PTG scan files carry a binary TLV header, not the text header the reader assumed, so real Cyclone exports failed to open. This PR decodes the actual layout and fixes the scanner pose convention.

Format (verified against real multi-chunk samples, byte-exact)

  • PTG\0 + magic 0x928FA3C7, then records [u32 nameLen][name\0][value]:
    • %%version, %%cols, %%rows, %%properties — bare u32
    • %%transform — 16 float64
    • name strings — [u32 len][bytes with trailing NUL]
    • %%header_begin / %%header_end — no value; the header ends at %%header_end
  • uint64 column offset table immediately after the header; offsets[0] equals the table end
  • per-column validity bitmask, most significant bit first; records for valid rows only (float/double XYZ + optional float intensity + optional RGB)
  • the pose matrix is row-vector (translation in the last row); it is transposed into the PclTransform column-vector convention on load

Changes

  • PtgHeader.Parse rewritten as a bounded binary TLV parser (1 MiB header, 256-byte names, version 1 and described keys only, finite transform values)
  • scan metadata now exposes the scanner name and creation date/time
  • synthetic fixtures emit the TLV layout; new tests for the rotation convention, metadata, unknown keys/versions, oversized names and truncated transforms
  • README format table and hardening row, CHANGELOG entry corrected

Verification

  • all PTG tests pass, including the real-file test against a three-chunk index (3 scans, 34,826,126 points)
  • CLI info and export verified end to end on the real sample
  • the only failing tests in the full suite are six pre-existing real-file fixture issues (E57/ReCap/PinPoint), reproduced on the base commit

@mahach666
mahach666 merged commit 6c6c86c into main Nov 25, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant